{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "suspected-valuable",
   "metadata": {},
   "source": [
    "## 组建数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "popular-invite",
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob\n",
    "from PIL import Image\n",
    "import numpy as np\n",
    "import re\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "creative-olympus",
   "metadata": {},
   "outputs": [],
   "source": [
    "def convert_img(img):\n",
    "    nimg = np.array(img)\n",
    "    ttmp = nimg.tolist()\n",
    "    for row in range(len(ttmp)):\n",
    "        for col in range(len(ttmp[0])):\n",
    "            ttmp[row][col] = np.average(ttmp[row][col])\n",
    "    return np.array(ttmp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "minor-summary",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = convert_img(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "reported-moses",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f4142cc0d90>"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD5CAYAAADhukOtAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAMjUlEQVR4nO3dXYxcdR3G8efptqBSwLbUTS3FQq0mvmDRtTGBGA1vtYkp3BB6gVVJ6oUkkGAi6oVcNkYgXhhMkYZqeJEIhF7gSy0QQgLYpamlL2oRa2hduqVVW1AC3f682FMz1D0zw8yZOcP+vp9kMmfOf2bOkwPPnrfpjCNCAKa/GXUHANAflB1IgrIDSVB2IAnKDiRB2YEkZnbzYtsrJP1I0pCkn0bEumbPP2fu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eGUPPtsv2B7u+3RmjJssD1ue2fDvLm2N9veW9zPqTnPrbYPFOtpu+2VfcyzyPYTtnfb3mX7xmJ+LeuoSZ7a1lErfd+Ntz0k6c+SLpe0X9JWSasjYndfg7w90z5JIxFR2/VR25+X9Jqkn0XEJ4p5P5B0JCLWFX8U50TEt2vMc6uk1yLih/3IcEqeBZIWRMQ222dKel7SVZr8gui+r6Mmea5RTeuolTq27MslvRgRL0XEm5IekLSqhhwDJSKeknTklNmrJG0spjdq8n+mOvPUJiLGImJbMX1M0h5JC1XTOmqSZ2DVUfaFkl5ueLxf9a+kkPRb28/bXltzlkbDETFWTL8iabjOMIUbbO8odvP7dljRyPZiSRdJek4DsI5OySMNwDqaCifoJl0SEZ+W9CVJ3yx2YQdKTB5v1X3p5E5JSyQtkzQm6bZ+B7A9W9JDkm6KiKONY3Wsoyny1L6OytRR9gOSFjU8PreYV5uIOFDcj0t6RJOHGoPgYHFsePIYcbzOMBFxMCImIuKEpLvU5/Vke5Ymi3VvRDxczK5tHU2Vp+511EwdZd8qaant822fJulaSZtqyCFJsn1GcYJFts+QdIWknc1f1TebJK0pptdIerTGLCfLdNLV6uN6sm1Jd0vaExG3NwzVso7K8tS5jlqKiL7fJK3U5Bn5v0j6Xh0ZGrJcIOkPxW1XXXkk3a/J3b63NHke43pJ8yRtkbRX0u8kza05z88lvSBphyZLtqCPeS7R5C76Dknbi9vKutZRkzy1raNWNz5BByTBCTogCcoOJEHZgSQoO5AEZQeSoOxAEpQdSIKyA0n8F7e0vEXxkv9DAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(datas[4])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "id": "earlier-quebec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 187,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "targets[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "pregnant-artwork",
   "metadata": {},
   "outputs": [],
   "source": [
    "png_files = glob.glob('datas/*/*.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "spiritual-geneva",
   "metadata": {},
   "outputs": [],
   "source": [
    "datas = []\n",
    "for foo in png_files:\n",
    "    x = Image.open(foo)\n",
    "    datas.append(convert_img(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "automatic-marking",
   "metadata": {},
   "outputs": [],
   "source": [
    "targets = [re.search(r'(\\d).png',foo).group(1) for foo in png_files]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "id": "elegant-guidance",
   "metadata": {},
   "outputs": [],
   "source": [
    "datas = np.array(datas)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "id": "nominated-reader",
   "metadata": {},
   "outputs": [],
   "source": [
    "# flatten the images\n",
    "n_samples = len(datas)\n",
    "data = datas.reshape((n_samples, -1))/255\n",
    "\n",
    "# Create a classifier: a support vector classifier\n",
    "clf = svm.SVC(gamma=0.1)\n",
    "\n",
    "# Split data into 50% train and 50% test subsets\n",
    "X_train, X_test, y_train, y_test = train_test_split(\n",
    "    data,targets , test_size=0.2, shuffle=False)\n",
    "\n",
    "# Learn the digits on the train subset\n",
    "clf.fit(X_train, y_train)\n",
    "\n",
    "# Predict the value of the digit on the test subset\n",
    "predicted = clf.predict(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "mounted-karen",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjwAAABNCAYAAACi7r7XAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYA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nQs6UWyUvU3h1IqrCLT3MNRa20eOGeffXbC6mZZmsctHb0gSc1CUVNTYxbkU089NS3GUWoFFhcXA86my+2ox02haS75XGVlpSndkOokrpJY9sorr3SVTxSAxx57LKn9ipchQ4aY56EcoQbL56bEyrMyXOkmcBQLcSWJVdFJBKHmXnNzUhTwDRs2mI1jMqKA7ZGWxWKxWCyWjCfskZbFYrFYLBZLJmAtPBaLxWKxWDIeq/BYLBaLxWLJeKzCY7FYLBaLJeOxCo/FYrFYLJaMxyo8FovFYrFYMh6r8FgsFovFYsl4/j+mx2sRVRqkVgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 720x216 with 10 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "_, axes = plt.subplots(nrows=1, ncols=10, figsize=(10, 3))\n",
    "for ax, image, prediction in zip(axes, X_test, predicted):\n",
    "    ax.set_axis_off()\n",
    "    image = image.reshape(30, 30)\n",
    "    ax.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')\n",
    "    ax.set_title(f'Pred: {prediction}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "id": "mysterious-finnish",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('clf_model.pkl','wb') as f:\n",
    "    pickle.dump(clf,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fabulous-pipeline",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "dramatic-courtesy",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Classification report for classifier SVC(gamma=0.1):\n",
      "              precision    recall  f1-score   support\n",
      "\n",
      "           0       1.00      1.00      1.00         3\n",
      "           1       1.00      1.00      1.00         3\n",
      "           2       1.00      1.00      1.00         3\n",
      "           3       1.00      1.00      1.00         3\n",
      "           4       1.00      1.00      1.00         3\n",
      "           5       1.00      1.00      1.00         3\n",
      "           6       1.00      1.00      1.00         3\n",
      "           7       1.00      1.00      1.00         3\n",
      "           8       1.00      1.00      1.00         3\n",
      "           9       1.00      1.00      1.00         3\n",
      "\n",
      "    accuracy                           1.00        30\n",
      "   macro avg       1.00      1.00      1.00        30\n",
      "weighted avg       1.00      1.00      1.00        30\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(f\"Classification report for classifier {clf}:\\n\"\n",
    "      f\"{metrics.classification_report(y_test, predicted)}\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fifth-camping",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "caroline-character",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ceramic-election",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'matplotlib'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-3-70db50b39b79>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatshow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdigits\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimages\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'matplotlib'"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt \n",
    "plt.gray() \n",
    "plt.matshow(digits.images[0]) \n",
    "plt.show() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "atomic-citation",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
